class LevelItem extends eui.ItemRenderer {
	public constructor() {
		super();
	}

	protected partAdded(partName: string, instance: any): void {
		super.partAdded(partName, instance);
	}


	protected childrenCreated(): void {
		super.childrenCreated();
		eui.Watcher.watch(this, ["data"], this.initData, this)

		this.init();

	}
	public img_icon: eui.Image;
	public img_crown: eui.Image;
	public group_star: eui.Group;
	/**
	 * 初始化数据
	 * @param e 为list的data源数据
	 */
	private initData(e) {

		// console.log(e);
		// console.log(this.data);
		//设置图片
		let src = e.src.replace(".", "_");
		this.img_icon.source = src;
		//是否最佳
		this.img_crown.visible = e.isCrown;
		//星级
		let len = this.group_star.numChildren
		for (let i = 0; i < len; i++) {
			let img = this.group_star.getChildAt(i) as eui.Image;
			if (i < e.starNum) {
				img.source = "start11_png"
			}
		}

	}
	private init() {
		this.touchChildren = false;
		this.addEventListener(egret.TouchEvent.TOUCH_TAP, (e) => {
			let dataId = e.target.data.id;
			console.log(dataId);
			
			SceneManager.Instance.switchScene(new GameScene(dataId));
		}, this);
		

	}


}